#ifndef _OBJECTMANAGER_
#define	_OBJECTMANAGER_

#include "Scripting/Scripting.hpp"
#include "BaseObject.hpp"

/**
 * A generic base class for world object managers.
 * This class uses and the 'objectmanager.lua' script that
 * provides separate environments for objects.
 */
class ObjectManager:public Scriptable{
protected:
    /** ScriptEngine used to manage objects*/
    ScriptEngine scriptEngine;
    
    void runScript(const char* script, Scriptable* object);
    void runScript(const char* script, Scriptable* o1, Scriptable* o2);
    void runStartup(BaseObject* object, const char* name);
    void runUpdate(BaseObject* object);
	void runDestroy(BaseObject* object);
public:
    /** Maximum number of objects in manager. */
    unsigned short size;
    
    ObjectManager();
    
    void init(const char* script);

    virtual void loadScript(const char* name);
    virtual void registerObject(Scriptable* object);
    virtual void registerGlobal(const char* name, Scriptable* object);

    virtual void bind(lua_State* luaState) = 0;
    virtual void push(lua_State* luaState) = 0;
};

#endif

